using UnityEngine;
using System.Collections;

public class Spawnspot : MonoBehaviour {

	public GameObject[] spawnables;

	GameObject spawnedInstance;

	public float spawnDelay = 10f;
	public float spawnCooldown = 0;

	void Start() {
		if(spawnables == null || spawnables.Length==0) {
			Debug.LogError("Didn't assign spawnables!!");
			this.enabled = false;
			return;
		}
	}

	void Update () {
		if(spawnedInstance == null) {
			spawnCooldown -= Time.deltaTime;
			if(spawnCooldown <= 0) {
				spawnCooldown = spawnDelay;
				spawnedInstance = (GameObject)Instantiate(spawnables[ Random.Range(0, spawnables.Length) ], transform.position, transform.rotation);
			}
		}
	}
}
